package cn.anecansaitin.firecrafting.client.integration.jei;

import cn.anecansaitin.firecrafting.api.common.crafting.IFireRecipe;
import cn.anecansaitin.firecrafting.common.menu.FireInterfaceMenu;
import mezz.jei.api.recipe.RecipeType;
import mezz.jei.api.recipe.transfer.IRecipeTransferInfo;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.inventory.Slot;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

//用于处理JEI内快速转移（配方右下角的加号）
public class FireCraftingRecipeTransferInfo implements IRecipeTransferInfo<FireInterfaceMenu, IFireRecipe> {
    @Override
    public @NotNull Class<FireInterfaceMenu> getContainerClass() {
        return FireInterfaceMenu.class;
    }

    @Override
    public @NotNull RecipeType<IFireRecipe> getRecipeType() {
        return JEIFireCraftingPlugin.FIRE_RECIPE;
    }

    //当开启过滤器gui时不要进行快捷转移
    @Override
    public boolean canHandle(@NotNull FireInterfaceMenu container, @NotNull IFireRecipe recipe) {
        return !container.isFilter();
    }

    //返回物品输入槽位
    @Override
    public @NotNull List<Slot> getRecipeSlots(@NotNull FireInterfaceMenu container, @NotNull IFireRecipe recipe) {
        ArrayList<Slot> slots = new ArrayList<>();
        for (int i = 36; i < 54; i++) {
            slots.add(container.getSlot(i));
        }

        return slots;
    }

    //返回所有除了物品输入槽
    @Override
    public @NotNull List<Slot> getInventorySlots(@NotNull FireInterfaceMenu container, @NotNull IFireRecipe recipe) {
        ArrayList<Slot> slots = new ArrayList<>();
        for (int i = 0; i < container.slots.size(); i++) {
            if (i < 36 || i >= 54) {
                slots.add(container.getSlot(i));
            }
        }

        return slots;
    }

    @SuppressWarnings("all")
    @Override
    public Class<IFireRecipe> getRecipeClass() {
        return IFireRecipe.class;
    }

    @SuppressWarnings("all")
    @Override
    public ResourceLocation getRecipeCategoryUid() {
        return FireCategories.ID;
    }
}
